home *** CD-ROM | disk | FTP | other *** search
/ Kit PC World De Ampliacion De Windows 95 / Kit PC World de ampliacion de Windows 95.iso / clarion / cw15 / examp15.z / CDPLAYER.CLW < prev    next >
Text File  |  1995-09-09  |  39KB  |  1,160 lines

  1.   PROGRAM
  2.  
  3.  INCLUDE('EQUATES.CLW')
  4.  INCLUDE('KEYCODES.CLW')
  5.  INCLUDE('CWWINAPI.INC')
  6.  
  7. MaximumTextLength    EQUATE(60)
  8. ActiveTimerDisplay   EQUATE(75)
  9. InactiveTimerDisplay EQUATE(200)
  10.  
  11. Repeat_None         EQUATE(0)
  12. Repeat_Track        EQUATE(1)
  13. Repeat_All          EQUATE(2)
  14.  
  15. Door_Open           EQUATE(1)
  16. Door_Closed         EQUATE(0)
  17.  
  18. CDAvailable         BYTE
  19. CDEjectPossible     BYTE
  20.  
  21. CDPlayerReady       BYTE
  22.  
  23. CDStatus            STRING(9)
  24. Old_CDStatus        STRING(9)
  25. StatusChanged       LONG
  26.  
  27. CDPlaying           LONG(0)
  28. CDPaused            LONG
  29.  
  30. StayOnTop           LONG
  31. Old_StayOnTop       LONG
  32.  
  33. ControlPanel        LONG
  34. Old_ControlPanel    LONG(-1)
  35.  
  36. RepeatMode          BYTE
  37. TrackMultiplier     BYTE
  38. NumberOfTracks      BYTE
  39.  
  40. CurrentTrack        LONG
  41. LastTrack           LONG
  42. NewAlbum            LONG(1)
  43.  
  44. RemainingTime       LONG
  45.  
  46. AlbumStarts         LONG
  47. AlbumTime           LONG
  48. TrackTime           LONG
  49. AlbumPosition       LONG
  50. TrackPosition       LONG
  51. AlbumRemaining      LONG
  52. TrackRemaining      LONG
  53.  
  54. INISettingsFound    BYTE
  55. TrackListPointer    LONG
  56. WindowX             LONG
  57. WindowY             LONG
  58. WindowHeight        LONG
  59. WindowWIdth         LONG
  60.  
  61. PlayList            STRING(MaximumTextLength)
  62. Old_PlayList        STRING(MaximumTextLength)
  63. PlayLists           QUEUE,PRE
  64.                       STRING(MaximumTextLength)
  65.                     END
  66.  
  67. CurrentTrackText    STRING(MaximumTextLength)
  68. PLTracks            QUEUE,PRE
  69. PLTrackTitle          STRING(MaximumTextLength)
  70. PLTrackNumber         LONG
  71.                     END
  72.  
  73. AutoPlay            BYTE
  74.  
  75. TrackList           QUEUE,PRE
  76. TrackTitle            STRING(MaximumTextLength)
  77.                     END
  78.  
  79. PlayListArray       STRING(2),DIM(100)
  80. PlayListText        STRING(200),OVER(PlayListArray)
  81. PlayListItems       LONG
  82.  
  83. ! Volume Structure
  84.  
  85. TrackRows           BYTE
  86. LoopCounter         BYTE
  87. ValueConstruct      LONG
  88. CurrentAlbumTitle   STRING(MaximumTextLength)
  89. CurrentAlbumArtist  STRING(MaximumTextLength)
  90. CurrentTrackTitle   STRING(MaximumTextLength)
  91.  
  92. StatusText          STRING(40)
  93. Old_StatusText      STRING(40)
  94. ShortText           STRING(20)
  95. DisplayTime         STRING(5)
  96. CurrentDisplayType  STRING(26)
  97.  
  98. Disp_AlbumElapsed   EQUATE(1)
  99. Disp_AlbumRemaining EQUATE(2)
  100. Disp_AlbumTotal     EQUATE(3)
  101. Disp_TrackElapsed   EQUATE(4)
  102. Disp_TrackRemaining EQUATE(5)
  103. Disp_TrackTotal     EQUATE(6)
  104. CurrentDisplayFlag  BYTE(1)
  105.  
  106. CompactDiscID       STRING(24)
  107. Old_CompactDiscID   STRING(24)
  108. NewCDLoaded         BYTE
  109.  
  110. HWND_NOTOPMOST      EQUATE(0fffeh)
  111. WM_QUERYENDSESSION  EQUATE(0011h)
  112. WM_ENDSESSION       EQUATE(0016h)
  113. GWL_WndProc         EQUATE(-4)
  114.  
  115. TitleRequired       BYTE
  116. Old_TitleRequired   BYTE
  117.  
  118. CDPlayerWindow      LONG
  119. WindowCurrentX      LONG
  120. WindowCurrentY      LONG
  121.  
  122.     MAP
  123.       AppWindowProc(USHORT,USHORT,SHORT,LONG),LONG,PASCAL
  124.       CD_PLAYER
  125.       MCIStatus(<STRING>),STRING,PROC
  126.       TranslateMFSTime(STRING),LONG
  127.       FixDisplayTime(LONG),STRING
  128.       SelectTrack(LONG,<LONG>)
  129.       StopPlayer
  130.       Pauseplayer
  131.       EditPlayList,LONG
  132.       EditPlayListTitle(STRING),STRING
  133.       SavePlayerStatus
  134.       AboutCDPlayer
  135.       INCLUDE('CWWinAPI.CLW')
  136.     END
  137.  
  138.   CODE
  139.   CD_Player
  140.  
  141. CD_PLAYER     PROCEDURE
  142. CDPlayWin WINDOW('Audio CD Player'),AT(,,135,229),FONT('MS Sans Serif',8,,FONT:regular),IMM,ICON('CD.ICO'), |
  143.          SYSTEM,RESIZE,AUTO,GRAY
  144.        MENUBAR
  145.          MENU('&File'),USE(?File)
  146.            ITEM('E&xit'),USE(?FileExit),STD(STD:Close)
  147.          END
  148.          MENU('&Options'),USE(?Options)
  149.            ITEM('&Playlist'),USE(?OptionsPlaylist)
  150.            ITEM('&Stay On Top'),USE(StayOnTop),CHECK
  151.            ITEM('&Control Panel'),USE(ControlPanel),CHECK
  152.            ITEM('&AutoPlay'),USE(AutoPlay),CHECK
  153.          END
  154.          MENU('&Help'),USE(?Help)
  155.            ITEM('&About'),USE(?HelpAbout)
  156.            ITEM('&Examples'),USE(?Examples),STD(STD:Help)
  157.          END
  158.        END
  159.        TOOLBAR,AT(0,0,135,23)
  160.          BUTTON,AT(4,1,18,18),TIP('Select the previous track'),USE(?CDSelectPrev),ICON('SMM_PREV.ICO')
  161.          BUTTON,AT(31,1,18,18),TIP('Play the current selections'),USE(?CDplaystop),ICON('SMM_PLAY.ICO')
  162.          BUTTON,AT(57,1,18,18),TIP('Pause the CD player'),USE(?CDpause),ICON('SMM_PAUS.ICO')
  163.          BUTTON,AT(84,1,18,18),TIP('Select the next track'),USE(?CDSelectNext),ICON('SMM_NEXT.ICO')
  164.          BUTTON,AT(112,1,18,18),TIP('Open the CD door'),USE(?CDDoor),ICON('SMM_CLOS.ICO')
  165.        END
  166.        BUTTON('&Repeat: None'),AT(2,70,64,14),TIP('Toggle the player''s repeat mode'),USE(?Repeat)
  167.        BUTTON('&Edit Playlist'),AT(69,70,64,14),TIP('Edit the album''s playlist'),USE(?Program)
  168.        BUTTON('1'),AT(1,44,20,10),TIP('Play a track from the ablum'),USE(?TRACK01)
  169.        BUTTON('2'),AT(23,44,20,10),TIP('Play a track from the ablum'),USE(?TRACK02)
  170.        BUTTON('3'),AT(45,44,20,10),TIP('Play a track from the ablum'),USE(?TRACK03)
  171.        BUTTON('4'),AT(67,44,20,10),TIP('Play a track from the ablum'),USE(?TRACK04)
  172.        BUTTON('5'),AT(89,44,20,10),TIP('Play a track from the ablum'),USE(?TRACK05)
  173.        BUTTON('6'),AT(1,56,20,10),TIP('Play a track from the ablum'),USE(?TRACK06)
  174.        BUTTON('7'),AT(23,56,20,10),TIP('Play a track from the ablum'),USE(?TRACK07)
  175.        BUTTON('8'),AT(45,56,20,10),TIP('Play a track from the ablum'),USE(?TRACK08)
  176.        BUTTON('9'),AT(67,56,20,10),TIP('Play a track from the ablum'),USE(?TRACK09)
  177.        BUTTON('10'),AT(89,56,20,10),TIP('Play a track from the ablum'),USE(?TRACK10)
  178.        BUTTON('+10'),AT(111,44,22,22),TIP('Get next set of play buttons'),USE(?TrackPlus)
  179.        GROUP('Current Album'),AT(1,86,133,32),BOXED
  180.          TEXT,AT(4,96,127,19),FONT(,,,FONT:bold),TIP('The album currently in the CD player'),USE(CurrentAlbumTitle), |
  181.              DISABLE,CENTER
  182.        END
  183.        GROUP('Artist'),AT(1,119,133,32),BOXED
  184.          TEXT,AT(4,129,127,19),FONT(,,,FONT:bold),TIP('The artist who produced the album'),USE(CurrentAlbumArtist), |
  185.              DISABLE,CENTER
  186.        END
  187.        GROUP('Playlist'),AT(1,153,133,23),USE(?Group4),BOXED
  188.          LIST,AT(5,162,125,10),TIP('The current playlist for this album'),USE(PlayList),FORMAT('160L@S40@'), |
  189.              DROP(4),FROM(PlayLists)
  190.        END
  191.        GROUP('Current Track'),AT(1,180,133,23),BOXED
  192.          LIST,AT(5,190,125,10),TIP('The track currently being played'),USE(CurrentTrackText),FORMAT('160L@S40@'), |
  193.              DROP(4),FROM(PLTracks)
  194.        END
  195.        REGION,AT(1,6,133,36),USE(?ChangeStatus)
  196.        GROUP('Player Status'),AT(1,1,133,41),USE(?Group1),BOXED
  197.          STRING(@S20),AT(16,9,103,10),FONT('MS Sans Serif',8,,FONT:bold),USE(StatusText),CENTER
  198.          STRING(@S5),AT(51,19,34,12),FONT('MS Sans Serif',10,0800000H,FONT:bold),USE(DisplayTime),CENTER
  199.          STRING(@S26),AT(11,30,113,10),USE(CurrentDisplayType),CENTER
  200.        END
  201.      END
  202.  
  203.   CODE
  204.   HELP('CW15EXAM')
  205.   DO InitializePlayer
  206.   OPEN(CDPlayWin)
  207.   TARGET{Prop:Double} = True
  208.   CDPlayerWindow = SetWindowLong(CDPlayWin{Prop:Handle},GWL_WndProc,ADDRESS(AppWindowProc))
  209.   SYSTEM{PROP:tipdelay} = 100
  210.   SYSTEM{PROP:tipdisplay} = 700
  211.   CDAvailable = False
  212.   TitleRequired = False
  213.   IF ControlPanel
  214.     TitleRequired = True
  215.     IF INISettingsFound
  216.       SETPOSITION(0,WindowX,WindowY,,23)
  217.     ELSE
  218.       SETPOSITION(0,,,,23)
  219.     END
  220.   ELSE
  221.     IF INISettingsFound
  222.       SETPOSITION(0,WindowX,WindowY,,)
  223.     END
  224.   END
  225.   Old_ControlPanel = ControlPanel
  226.   IF StayOnTop
  227.     SetWindowPos(TARGET{Prop:Handle},HWND_TOPMOST,0,0,0,0,SWP_NOACTIVATE+SWP_NOMOVE+SWP_NOSIZE)
  228.   END
  229.   Old_StayOnTop = StayOnTop
  230.   ACCEPT
  231.     CASE ACCEPTED()
  232.     OF ?StayOnTop
  233.       IF Old_StayOnTop <> StayOnTop
  234.         Old_StayOnTop = StayOnTop
  235.         IF StayOnTop
  236.           SetWindowPos(TARGET{Prop:Handle},HWND_TOPMOST,0,0,0,0,SWP_NOACTIVATE+SWP_NOMOVE+SWP_NOSIZE)
  237.         ELSE
  238.           SetWindowPos(TARGET{Prop:Handle},HWND_NOTOPMOST,0,0,0,0,SWP_NOACTIVATE+SWP_NOMOVE+SWP_NOSIZE)
  239.         END
  240.       END
  241.     OF ?ControlPanel
  242.       IF Old_ControlPanel <> ControlPanel
  243.         Old_ControlPanel = ControlPanel
  244.         IF ControlPanel
  245.           TARGET{Prop:Height} = 23
  246.         ELSE
  247.           TARGET{Prop:Height} = 229
  248.           TARGET{Prop:Text} = 'Audio CD Player'
  249.         END
  250.       END
  251.     OF ?Repeat
  252.       RepeatMode += 1
  253.       IF RepeatMode > Repeat_All
  254.         RepeatMode = Repeat_None
  255.       END
  256.       DO DisplayRepeatButton
  257.     OF ?Program
  258.     OROF ?OptionsPlaylist
  259.       IF EditPlayList()
  260.         StopPlayer
  261.         DO DetectCDStatus
  262.         DO InitializeNewAlbum
  263.       END
  264.     OF ?HelpAbout
  265.       AboutCDPlayer
  266.     OF ?Examples
  267.       HELP
  268.     OF ?ChangeStatus
  269.       CurrentDisplayFlag += 1
  270.       IF CurrentDisplayFlag = 7
  271.         CurrentDisplayFlag = 1
  272.       END
  273.       DO GetAndDisplayTrackStatus
  274.     OF ?CDDoor
  275.       IF MCIStatus() = 'open'
  276.         MCIStatus('set cdaudio door closed')
  277.       ELSE
  278.         MCIStatus('set cdaudio door open')
  279.       END
  280.     OF ?CDPlayStop
  281.       IF NOT CDPlaying
  282.         SelectTrack(CHOICE(?CurrentTrackText),1)
  283.       ELSE
  284.         StopPlayer
  285.       END
  286.     OF ?CDPause
  287.       PausePlayer
  288.     OF ?CDSelectPrev
  289.       SelectTrack(POINTER(PLTracks)-1,CDPlaying)
  290.     OF ?CDSelectNext
  291.       SelectTrack(POINTER(PLTracks)+1,CDPlaying)
  292.     OF ?TRACK01 TO ?TRACK10
  293.       IF POINTER(PlayLists) > 1
  294.         IF MESSAGE('This will change the order of play to the track order on the album.  Are you certain you want to do this?','Track Button Selected',Icon:Question,Button:Yes+Button:No,Button:No) = Button:No
  295.           CYCLE
  296.         END
  297.         GET(PlayLists,1)
  298.         DO LoadNewPlayList
  299.       END
  300.       SelectTrack((FIELD()-?TRACK01+1) + (TrackMultiplier * 10),1)
  301.     OF ?TrackPlus
  302.       TrackMultiplier += 1
  303.       IF TrackMultiplier = TrackRows
  304.         TrackMultiplier = 0
  305.       END
  306.       DO DisplayRandomAccessButtons
  307.     OF ?CurrentTrackText
  308.       SelectTrack(CHOICE(?CurrentTrackText),CDPlaying)
  309.     OF ?PlayList
  310.       IF Old_PlayList <> PlayList
  311.         StopPlayer
  312.         GET(PlayLists,CHOICE(?PlayList))
  313.         DO LoadNewPlaylist
  314.         IF AutoPlay
  315.           CDPlaying = True
  316.           SelectTrack(1,CDPlaying)
  317.         END
  318.       END
  319.     END
  320.     CASE EVENT()
  321.     OF EVENT:OpenWindow
  322.       DO AttemptCDInitialize
  323.       IF NOT CDAvailable
  324.         DO DisableAccessButtons
  325.         DISABLE(?CDDoor)
  326.         TARGET{Prop:Timer} = InactiveTimerDisplay
  327.         StayOnTop = False
  328.         IF TitleRequired
  329.           TARGET{Prop:Text} = 'Device Not Available'
  330.         END
  331.         Old_TitleRequired = TitleRequired
  332.       ELSE
  333.         IF TitleRequired
  334.           IF AlbumPosition <> '00:00'
  335.             TARGET{Prop:Text} = 'CD ' & CLIP(ShortText) & '  (' & FixDisplayTime((AlbumPosition - TrackPosition) + AlbumStarts) & ')'
  336.           ELSE
  337.             TARGET{Prop:Text} = 'CD ' & CLIP(StatusText)
  338.           END
  339.         END
  340.         Old_TitleRequired = TitleRequired
  341.       END
  342.     OF EVENT:CloseWindow
  343.       SavePlayerStatus
  344.       BREAK
  345.     OF EVENT:Timer
  346.       TitleRequired = False
  347.       IF ControlPanel OR TARGET{Prop:Iconize}
  348.         TitleRequired = True
  349.       END
  350.       IF NOT CDAvailable
  351.         DO AttemptCDInitialize
  352.         IF TitleRequired
  353.           TARGET{Prop:Text} = 'Device Not Available'
  354.         ELSIF Old_TitleRequired <> TitleRequired
  355.           TARGET{Prop:Text} = 'Audio CD Player'
  356.         END
  357.       ELSE
  358.         DO DetectCDStatus
  359.         IF TitleRequired
  360.           IF AlbumPosition <> '00:00'
  361.             TARGET{Prop:Text} = 'CD ' & CLIP(ShortText) & '  (' & FixDisplayTime((AlbumPosition - TrackPosition) + AlbumStarts) & ')'
  362.           ELSE
  363.             TARGET{Prop:Text} = 'CD ' & CLIP(StatusText)
  364.           END
  365.         ELSIF Old_TitleRequired <> TitleRequired
  366.           TARGET{Prop:Text} = 'Audio CD Player'
  367.         END
  368.       END
  369.       Old_TitleRequired = TitleRequired
  370.     OF Event:Moved
  371.       IF NOT TARGET{Prop:Iconize}
  372.         GETPOSITION(0,WindowCurrentX,WindowCurrentY,WindowWidth,WindowHeight)
  373.       END
  374.     END
  375.   END
  376.   CLOSE(CDPlayWin)
  377.  
  378. !-------------------------------------------------------------------------
  379. InitializePlayer ROUTINE
  380.   INISettingsFound = False
  381.   IF GETINI('CD Player Settings','Product','','CW_CD.INI')
  382.     INISettingsFound = True
  383.     StayOnTop = GETINI('CD Player Settings','Stay On Top',,'CW_CD.INI')
  384.     ControlPanel = GETINI('CD Player Settings','Control Panel',,'CW_CD.INI')
  385.     AutoPlay = GETINI('CD Player Settings','Auto Play',,'CW_CD.INI')
  386.     CurrentDisplayFlag = GETINI('CD Player Settings','Display Mode',1,'CW_CD.INI')
  387.     WindowX = GETINI('CD Player Settings','Window X',,'CW_CD.INI')
  388.     WindowY = GETINI('CD Player Settings','Window Y',,'CW_CD.INI')
  389.   ELSE
  390.     PUTINI('CD Player Settings','Product','Clarion for Windows CD Player Demo','CW_CD.INI')
  391.     PUTINI('CD Player Settings','Copyright','1995, TopSpeed Corporation','CW_CD.INI')
  392.   END
  393.  
  394. !-------------------------------------------------------------------------
  395. DetectCDStatus ROUTINE
  396.   IF MCIStatus('status cdaudio ready')
  397.     CDStatus = MCIStatus()
  398.   ELSE
  399.     CDStatus = MCIStatus()
  400.     IF CDStatus <> 'open'
  401.       CDStatus = 'not ready'
  402.     END
  403.   END
  404.   IF CDStatus <> Old_CDStatus
  405.     DO ProcessOldStatus
  406.   END
  407.   DO ProcessStatus
  408.   Old_CDStatus = CDStatus
  409.  
  410. !-------------------------------------------------------------------------
  411. ProcessOldStatus ROUTINE
  412.   CASE Old_CDStatus
  413.   OF 'open'
  414.     ?CDDoor{Prop:Icon} = '~SMM_CLOS.ICO'
  415.     ?CDDoor{Prop:ToolTip} = 'Open the CD door'
  416.     IF CDStatus <> 'not ready'
  417.       IF MCIStatus('status cdaudio media present')
  418.         DO EnableAccessButtons
  419.       END
  420.     END
  421.   OF 'playing'
  422.     IF CDStatus = 'stopped'
  423.       IF NOT CDPaused AND CDPlaying
  424.         CASE RepeatMode
  425.         OF Repeat_None
  426.           IF POINTER(PLTracks) = RECORDS(PLTracks)
  427.             CDPlaying = False
  428.           ELSE
  429.             SelectTrack(POINTER(PLTracks)+1,CDPlaying)
  430.           END
  431.         OF Repeat_Track
  432.           SelectTrack(POINTER(PLTracks),CDPlaying)
  433.         OF Repeat_All
  434.           SelectTrack(1,CDPlaying)
  435.         END
  436.       END
  437.     ELSE
  438.       ?CDPlayStop{Prop:Icon} = '~SMM_PLAY.ICO'
  439.       ?CDPlayStop{Prop:ToolTip} = 'Play the current selections'
  440.       DISABLE(?CDPause)
  441.     END
  442.   END
  443.   CASE CDStatus
  444.   OF 'not ready'
  445.     ?CDDoor{Prop:Icon} = '~SMM_CLOS.ICO'
  446.     ?CDDoor{Prop:ToolTip} = 'Open the CD door'
  447.     StatusText = 'Not Ready'
  448.     ShortText = 'Not Ready'
  449.     DisplayTime = ''
  450.     CurrentDisplayType = ''
  451.     DO DisableAccessButtons
  452.     AlbumPosition = ''
  453.   OF 'open'
  454.     ?CDDoor{Prop:Icon} = '~SMM_OPEN.ICO'
  455.     ?CDDoor{Prop:ToolTip} = 'Close the CD door'
  456.     StatusText = 'Door Open'
  457.     ShortText = 'Door Open'
  458.     DisplayTime = ''
  459.     CurrentDisplayType = ''
  460.     DO DisableAccessButtons
  461.     AlbumPosition = ''
  462.   OF 'playing'
  463.     CDPlaying = True
  464.     CDPaused = False
  465.     ?CDPlayStop{Prop:Icon} = '~SMM_STOP.ICO'
  466.     ?CDPlayStop{Prop:ToolTip} = 'Stop the CD Player'
  467.     ENABLE(?CDPause)
  468.     Old_StatusText = StatusText
  469.     StatusText = 'Scanning Disc'
  470.     DISPLAY(?StatusText)
  471.     DO GetCompactDiscID
  472.     IF NewCDLoaded
  473.       DO InitializeNewAlbum
  474.     END
  475.     StatusText = Old_StatusText
  476.     DISPLAY(?StatusText)
  477.   OF 'stopped'
  478.     IF Old_CDStatus = 'playing' AND CDPaused
  479.       DO GetAndDisplayTrackStatus
  480.       StatusText = 'Paused on track ' & CurrentTrack
  481.       ShortText = 'Paused'
  482.       CDPlaying = True
  483.       ?CDPause{Prop:Icon} = '~SMM_PAU2.ICO'
  484.       ?CDPause{Prop:ToolTip} = 'Restart the CD player'
  485.     ELSE
  486.       StatusText = 'Stopped'
  487.       ShortText = 'Stopped'
  488.       MCIStatus('seek cdaudio to start')
  489.       ?CDPause{Prop:Icon} = '~SMM_PAUS.ICO'
  490.       ?CDPause{Prop:ToolTip} = 'Pause the CD player'
  491.       ?CDPlayStop{Prop:Icon} = '~SMM_PLAY.ICO'
  492.       ?CDPlayStop{Prop:ToolTip} = 'Play the current selection(s)'
  493.       DO EnableAccessButtons
  494.       Old_StatusText = StatusText
  495.       StatusText = 'Scanning Disc'
  496.       AlbumPosition = ''
  497.       DISPLAY(?StatusText)
  498.       DO GetCompactDiscID
  499.       IF NewCDLoaded OR Old_CDStatus = 'open'
  500.         DO InitializeNewAlbum
  501.         IF AutoPlay
  502.           CDPlaying = True
  503.           SelectTrack(1,CDPlaying)
  504.         END
  505.       END
  506.       StatusText = Old_StatusText
  507.       DISPLAY(?StatusText)
  508.       DO GetAndDisplayTrackStatus
  509.     END
  510.   END
  511.  
  512. !-------------------------------------------------------------------------
  513. ProcessStatus ROUTINE
  514.   CASE CDStatus
  515.   OF 'playing'
  516.     DO GetAndDisplayTrackStatus
  517.     StatusText = 'Playing Track ' & CurrentTrack
  518.     ShortText = 'Playing ' & CurrentTrack
  519.   END
  520.  
  521. !--------------------------------------------------------
  522. AttemptCDInitialize ROUTINE
  523.   CDEjectPossible = False
  524.   IF MCIStatus('open cdaudio shareable') <> '1'
  525.     StatusText = 'CD Player Not Available'
  526.     TARGET{PROP:TIMER} = InactiveTimerDisplay
  527.     DO DisableAccessButtons
  528.   ELSE
  529.     CDAvailable = True
  530.     IF MCIStatus('capability cdaudio can eject')
  531.       CDEjectPossible = True
  532.       ENABLE(?CDDoor)
  533.     END
  534.     DO EnableAccessButtons
  535.     DO DetectCDStatus
  536.     TARGET{Prop:Timer} = ActiveTimerDisplay
  537.   END
  538.  
  539. !--------------------------------------------------------
  540. EnableAccessButtons ROUTINE
  541.   ENABLE(?CDSelectPrev,?CDSelectNext)
  542.   ENABLE(?Repeat,?Program)
  543.   ENABLE(?Track01,?CurrentTrackText)
  544.  
  545. !--------------------------------------------------------
  546. DisableAccessButtons ROUTINE
  547.   DISABLE(?CDSelectPrev,?CDSelectNext)
  548.   DISABLE(?Repeat,?Program)
  549.   DISABLE(?Track01,?CurrentTrackText)
  550.  
  551. !--------------------------------------------------------
  552. DisplayRepeatButton ROUTINE
  553.   CASE RepeatMode
  554.   OF Repeat_None
  555.     ?Repeat{Prop:Text} = 'Repeat: None'
  556.   OF Repeat_Track
  557.     ?Repeat{Prop:Text} = 'Repeat: Track'
  558.   OF Repeat_All
  559.     ?Repeat{Prop:Text} = 'Repeat: All'
  560.   END
  561.  
  562. !--------------------------------------------------------
  563. DisplayRandomAccessButtons ROUTINE
  564.   LOOP LoopCounter = 1 to 10
  565.     ValueConstruct = (?Track01 - 1) + LoopCounter
  566.     IF LoopCounter + (TrackMultiplier * 10) > NumberOfTracks
  567.       HIDE(ValueConstruct,?Track10)
  568.     ELSE
  569.       UNHIDE(ValueConstruct,?Track10)
  570.       ValueConstruct{Prop:Text} = (TrackMultiplier * 10) + LoopCounter
  571.     END
  572.   END
  573.  
  574. !--------------------------------------------------------
  575. GetCompactDiscID ROUTINE
  576.   NumberOfTracks = MCIStatus('status cdaudio number of tracks')
  577.   CompactDiscID = FORMAT(NumberOfTracks,@N2)
  578.   CompactDiscID = CLIP(CompactDiscID) & TranslateMFSTime(MCIStatus('status cdaudio length'))
  579.   CompactDiscID = CLIP(CompactDiscID) & TranslateMFSTime(MCIStatus('status cdaudio length track 1'))
  580.   IF NumberOfTracks > 1
  581.     CompactDiscID = CLIP(CompactDiscID) & TranslateMFSTime(MCIStatus('status cdaudio length track 2'))
  582.     IF NumberOfTracks > 2
  583.       CompactDiscID = CLIP(CompactDiscID) & TranslateMFSTime(MCIStatus('status cdaudio length track 3'))
  584.     END
  585.   END
  586.   NewCDLoaded = False
  587.   IF Old_CompactDiscID <> CompactDiscID
  588.     NewCDLoaded = True
  589.     Old_CompactDiscID = CompactDiscID
  590.   END
  591.  
  592. !--------------------------------------------------------
  593. InitializeNewAlbum ROUTINE
  594.   TrackRows = INT((NumberOfTracks - 1) / 10) + 1
  595.   CLEAR(TrackMultiplier)
  596.   IF TrackRows = 1
  597.     HIDE(?TrackPlus)
  598.   ELSE
  599.     UNHIDE(?TrackPlus)
  600.   END
  601.   DO DisplayRandomAccessButtons
  602.   CLEAR(RepeatMode)
  603.   DO DisplayRepeatButton
  604.   INISettingsFound = False
  605.   FREE(TrackList)
  606.   FREE(PlayLists)
  607.   Playlists = 'Album Order'
  608.   ADD(PlayLists)
  609.   CurrentAlbumTitle = GETINI(CompactDiscID,'Title',,'CW_CD.INI')
  610.   IF CurrentAlbumTitle
  611.     INISettingsFound = True
  612.     CurrentAlbumArtist = GETINI(CompactDiscID,'Artist',,'CW_CD.INI')
  613.   ELSE
  614.     CurrentAlbumTitle = 'New Album'
  615.     CurrentAlbumArtist = ''
  616.   END
  617.   LOOP LoopCounter = 1 TO NumberOfTracks
  618.     IF INISettingsFound
  619.       TrackTitle = GETINI(CompactDiscID,'Track ' & LoopCounter,,'CW_CD.INI')
  620.     ELSE
  621.       TrackTitle = 'Track ' & LoopCounter
  622.     END
  623.     ADD(TrackList)
  624.   END
  625.   IF INISettingsFound
  626.     LOOP LoopCounter = 1 TO GETINI(CompactDiscID,'PlayList Count',,'CW_CD.INI')
  627.       PlayLists = GETINI(CompactDiscID,'PlayList ' & LoopCounter & ' Title',,'CW_CD.INI')
  628.       ADD(PlayLists)
  629.     END
  630.   END
  631.   GET(PlayLists,1)
  632.   PlayList = PlayLists
  633.   DO LoadNewPlayList
  634. !--------------------------------------------------------
  635. LoadNewPlayList ROUTINE
  636.   PlayList = PlayLists
  637.   FREE(PLTracks)
  638.   IF POINTER(PlayLists) = 1
  639.     LOOP LoopCounter = 1 TO NumberOfTracks
  640.       GET(TrackList,LoopCounter)
  641.       PLTrackNumber = LoopCounter
  642.       PLTrackTitle = TrackTitle
  643.       ADD(PLTracks)
  644.     END
  645.   ELSE
  646.     PlayListText = GETINI(CompactDiscID,'PlayList ' & POINTER(PlayLists) - 1,,'CW_CD.INI')
  647.     PlayListItems = PlayListArray[1]
  648.     LOOP LoopCounter = 2 TO PlayListItems + 1
  649.       ValueConstruct = PlayListArray[LoopCounter]
  650.       GET(TrackList,ValueConstruct)
  651.       PLTrackNumber = ValueConstruct
  652.       PLTrackTitle = TrackTitle
  653.       ADD(PLTracks)
  654.     END
  655.   END
  656.   IF RECORDS(PLTracks)
  657.     GET(PLTracks,1)
  658.     CurrentTrackText = PLTrackTitle
  659.   ELSE
  660.     CurrentTrackText = ''
  661.   END
  662.   DISPLAY(?CurrentTrackText)
  663.   Old_PlayList = PlayList
  664. !--------------------------------------------------------
  665. GetAndDisplayTrackStatus ROUTINE
  666.  
  667.   CurrentTrack = MCIStatus('status cdaudio current track')
  668.   IF NewAlbum
  669.     AlbumStarts = TranslateMFSTime(MCIStatus('status cdaudio start position'))
  670.     AlbumTime = TranslateMFSTime(MCIStatus('status cdaudio length'))
  671.     NewAlbum = False
  672.     DO InitializeNewAlbum
  673.   END
  674.   IF CurrentTrack <> LastTrack
  675.     TrackPosition = TranslateMFSTime(MCIStatus('status cdaudio position track ' & CurrentTrack))
  676.     TrackTime = TranslateMFSTime(MCIStatus('status cdaudio length track ' & CurrentTrack))
  677.     LastTrack = CurrentTrack
  678.     GET(TrackList,CurrentTrack)
  679.     CurrentTrackText = TrackTitle
  680.     DISPLAY
  681.   END
  682.   AlbumPosition = TranslateMFSTime(MCIStatus('status cdaudio position'))
  683.   AlbumPosition = AlbumPosition - AlbumStarts
  684.   AlbumRemaining  = AlbumTime - AlbumPosition
  685.   TrackRemaining  = TrackTime - (AlbumPosition - TrackPosition)
  686.   EXECUTE(CurrentDisplayFlag)
  687.     BEGIN
  688.       DisplayTime = FixDisplayTime(AlbumPosition)
  689.       CurrentDisplayType = 'Album Elapsed'
  690.     END
  691.     BEGIN
  692.       DisplayTime = FixDisplayTime(AlbumRemaining)
  693.       CurrentDisplayType = 'Album Remaining'
  694.     END
  695.     BEGIN
  696.       DisplayTime = FixDisplayTime(AlbumTime)
  697.       CurrentDisplayType = 'Album Total'
  698.     END
  699.     BEGIN
  700.       DisplayTime = FixDisplayTime((AlbumPosition - TrackPosition) + AlbumStarts)
  701.       CurrentDisplayType = 'Track Elapsed'
  702.     END
  703.     BEGIN
  704.       DisplayTime = FixDisplayTime(TrackRemaining)
  705.       CurrentDisplayType = 'Track Remaining'
  706.     END
  707.     BEGIN
  708.       DisplayTime = FixDisplayTime(TrackTime)
  709.       CurrentDisplayType = 'Track Total'
  710.     END
  711.   END
  712.  
  713. !===================================================================
  714. StopPlayer PROCEDURE
  715.  
  716.   CODE
  717.   MCIStatus('stop cdaudio')
  718.   MCIStatus('seek cdaudio to start')
  719.   CDPlaying = False
  720.   CDPaused = False
  721.  
  722. !===================================================================
  723. PausePlayer PROCEDURE
  724.  
  725.   CODE
  726.   IF CDPaused
  727.     MCIStatus('play cdaudio')
  728.     CDPaused = False
  729.   ELSE
  730.     MCIStatus('pause cdaudio')
  731.     CDPaused = True
  732.   END
  733.  
  734. !===================================================================
  735. SelectTrack PROCEDURE(CurrentPLTrack,PlayThisSelection)
  736. NextStop         LONG
  737.  
  738.   CODE
  739.   IF CurrentPLTrack > RECORDS(PLTracks)
  740.     GET(PLTracks,1)
  741.   ELSIF CurrentPLTrack < 1
  742.     GET(PLTracks,RECORDS(PLTracks))
  743.   ELSE
  744.     GET(PLTracks,CurrentPLTrack)
  745.   END
  746.   IF PlayThisSelection
  747.     MCIStatus('set cdaudio time format tmsf')
  748.     IF POINTER(PlayLists) = 1 OR PLTrackNumber = RECORDS(Tracklist)
  749.       MCIStatus('play cdaudio from ' & PLTrackNumber)
  750.     ELSE
  751.       NextStop = PLTrackNumber + 1
  752.       MCIStatus('play cdaudio from ' & PLTrackNumber & ' to ' & NextStop)
  753.     END
  754.     MCIStatus('set cdaudio time format msf')
  755.     CDPlaying = True
  756.     CDPaused = False
  757.   END
  758.   CurrentTrackText = PLTrackTitle
  759. !--------------------------------------------------------
  760. FixDisplayTime FUNCTION(InputTime)
  761.  
  762. ConstructTime       GROUP,PRE
  763. ConstructHours        STRING(@P##:P)
  764. ReturnGroup           GROUP,PRE
  765. ConstructMinutes        STRING(@P##:P)
  766. ConstructSeconds        STRING(@P##P)
  767.                       END
  768.                     END
  769. NumberOfHours       LONG
  770.   CODE
  771.   ConstructTime = FORMAT(InputTime,@T4)
  772.   ConstructMinutes = ConstructMinutes + (ConstructHours * 60)
  773.   RETURN(ReturnGroup)
  774.  
  775. !===================================================================
  776. TranslateMFSTime FUNCTION(InputString)
  777.  
  778. ConstructTime       GROUP,PRE
  779. ConstructHours        STRING(@P##:P)
  780. ConstructMinutes      STRING(@P##:P)
  781. ConstructSeconds      STRING(@P##P)
  782.                     END
  783.  
  784. msfTimeStamp        GROUP,PRE
  785. msfStampMinutes       STRING(@P##:P)
  786. msfStampSeconds       STRING(@P##:P)
  787. msfStampFrames        STRING(@P##P)
  788.                     END
  789.  
  790.   CODE
  791.   msfTimeStamp = InputString
  792.   IF msfStampMinutes > 59
  793.     ConstructHours = 1
  794.     ConstructMinutes = msfStampMinutes - 60
  795.   ELSE
  796.     ConstructHours = 0
  797.     ConstructMinutes = msfStampMinutes
  798.   END
  799.   ConstructSeconds = msfStampSeconds
  800.   RETURN(DEFORMAT(ConstructTime,@T4))
  801. !===================================================================
  802. MCIStatus FUNCTION(MCIStatusRequest)
  803.  
  804. MCIRequestValue     CSTRING(100)
  805. MCIReturnValue      CSTRING(100)
  806. MCIErrorString      STRING(100)
  807.  
  808. MCIErrorNotReady    EQUATE(291)
  809.  
  810.   CODE
  811.   IF OMITTED(1)
  812.     MCIRequestValue = 'status cdaudio mode'
  813.   ELSE
  814.     MCIRequestValue = MCIStatusRequest
  815.   END
  816.   CLEAR(MCIErrorString)
  817.   MCIErrorString = MCISendString(MCIRequestValue,MCIReturnValue,128,0)
  818.   IF MCIErrorString <> '0'
  819.     IF MCIErrorString = '265'
  820.       RETURN('1')
  821.     ELSE
  822.       RETURN(MCIErrorString)
  823.     END
  824.   ELSE
  825.     CASE MCIReturnValue
  826.     OF 'true'
  827.       RETURN('1')
  828.     OF 'false'
  829.       RETURN('')
  830.     OF '1'
  831.     OROF '2'
  832.       RETURN('1')
  833.     ELSE
  834.       RETURN(MCIReturnValue)
  835.     END
  836.   END
  837.  
  838. !===================================================================
  839. EditPlayList FUNCTION
  840. CurrentSelection LONG
  841.  
  842. HoldPlayLists   QUEUE,PRE
  843. HoldPlayListName  STRING(MaximumTextLength)
  844. HoldPlayListArray STRING(2),DIM(100)
  845. HoldPlayListText  STRING(200),OVER(HoldPlayListArray)
  846.                 END
  847.  
  848. PlayListEditQueue QUEUE,PRE
  849. PlayListTrackName   STRING(MaximumTextLength)
  850. PlayListTrackNumber LONG
  851.                   END
  852.  
  853. EditPlayListName  STRING(MaximumTextLength)
  854. PlaylistCount     LONG
  855. EditCompleted     LONG
  856. EditWindow WINDOW('Edit an Album''s Playlist'),AT(,,332,230),FONT('MS Sans Serif',8,,FONT:regular),STATUS, |
  857.          GRAY
  858.        SHEET,AT(6,5,319,201),USE(?Sheet1)
  859.          TAB('Album Properties'),USE(?Tab1)
  860.            GROUP('&Artist'),AT(15,22,148,24),BOXED
  861.              ENTRY(@S60),AT(21,32,137,12),TIP('The name of the artist'),USE(CurrentAlbumArtist),DROPID('Move Track'),MSG('Enter the name of the album''s artist here.')
  862.            END
  863.            GROUP('&Title'),AT(15,48,148,24),USE(?Group2),BOXED
  864.              ENTRY(@s60),AT(21,58),TIP('The title of the album'),USE(CurrentAlbumTitle),DROPID('Move Track'),MSG('Enter the title of the album here')
  865.            END
  866.            LIST,AT(15,74,148,108),TIP('The music selections on the album'),USE(?TrackList),SKIP,FORMAT('240L@S60@'), |
  867.                FROM(TrackList),DRAGID('Add Track'),DROPID('Move Track')
  868.            ENTRY(@s60),AT(15,186,148,12),TIP('Edit a track''s title'),ALRT(UpKey),ALRT(DownKey),ALRT(PgUpKey), |
  869.                ALRT(PgDnKey),ALRT(CtrlPgUp),ALRT(CtrlPgDn),USE(TrackTitle),DROPID('Move Track'),MSG('Enter the title of the track.  Use the cursor keys to select new tracks to edit.')
  870.            GROUP('&Playlist'),AT(171,22,149,47),USE(?Group3),BOXED
  871.              LIST,AT(177,32,137,12),TIP('Edit the name of a customized playlist'),USE(EditPlayListName), |
  872.                  FORMAT('240L@s60@'),DROP(5),FROM(HoldPlayLists),DROPID('Move Track'),MSG('Select a new playlist to edit')
  873.            END
  874.            LIST,AT(171,74,149,124),TIP('The music selections of a playlist'),USE(?PlayListEditQueue), |
  875.                FORMAT('240L@S60@'),FROM(PlayListEditQueue),DRAGID('Move Track'),DROPID('Add Track'),DROPID('Move Track'),MSG('Drag tracks to the playlist to add them.  Drag tracks from the playlist to remove them.')
  876.            BUTTON('&New'),AT(177,49,39,12),TIP('Add a customized playlist'),KEY(InsertKey),USE(?NewPlayList), |
  877.                DROPID('Move Track'),MSG('Add a new playlist')
  878.            BUTTON('&Edit'),AT(226,49,39,12),TIP('Edit the name of a customized playlist'),USE(?EditPlayList), |
  879.                DROPID('Move Track'),MSG('Edit the current playlist''s name')
  880.            BUTTON('&Remove'),AT(275,49,39,12),TIP('Remove a customized playlist'),KEY(DeleteKey),USE(?DeletePlayList), |
  881.                DROPID('Move Track'),MSG('Remove a playlist')
  882.          END
  883.        END
  884.        BUTTON('OK'),AT(199,210,40,14),TIP('Accept your changes and return to the player'),USE(?OK),DEFAULT, |
  885.            DROPID('Move Track'),MSG('Accept changes and exit')
  886.        BUTTON('&Cancel'),AT(243,210,40,14),TIP('Cancel your changes and return to the player'),USE(?Cancel), |
  887.            DROPID('Move Track'),MSG('Cancel changes and exit')
  888.        BUTTON('&Apply'),AT(287,210,40,14),TIP('Apply your changes and keep editing'),USE(?Apply),DROPID('Move Track'),MSG('Apply changes and keep editing')
  889.        REGION,AT(0,0,333,230),USE(?TrashCan),FULL,DROPID('Move Track')
  890.      END
  891. CurrentWindow LONG
  892.   CODE
  893.   EditCompleted = False
  894.   OPEN(EditWindow)
  895.   GET(TrackList,1)
  896.   FREE(PlayListEditQueue)
  897.   FREE(HoldPlayLists)
  898.   PlaylistCount = GETINI(CompactDiscID,'PlayList Count',,'CW_CD.INI')
  899.   LOOP LoopCounter = 1 TO PlaylistCount
  900.     HoldPlayListName = GETINI(CompactDiscID,'PlayList ' & LoopCounter & ' Title',,'CW_CD.INI')
  901.     HoldPlayListText = GETINI(CompactDiscID,'PlayList ' & LoopCounter,,'CW_CD.INI')
  902.     ADD(HoldPlayLists)
  903.   END
  904.   IF NOT RECORDS(HoldPlayLists)
  905.     DISABLE(?EditPlayListName,?PlayListEditQueue)
  906.     DISABLE(?EditPlayList,?DeletePlayList)
  907.     CLEAR(HoldPlayLists)
  908.   ELSE
  909.     GET(HoldPlayLists,1)
  910.     ?EditPlayListName{Prop:Selected} = 1
  911.     DO LoadEditPlayList
  912.     EditPlayListName = HoldPlayListName
  913.   END
  914.   ?TrackList{Prop:Selected} = 1
  915.   ACCEPT
  916.     IF EVENT() = Event:Drop AND DROPID() = 'Move Track'
  917.       IF FIELD() = ?PlayListEditQueue
  918.         CurrentSelection = ?PlayListEditQueue{PropList:MouseUpRow}
  919.         DELETE(PlayListEditQueue)
  920.         ADD(PlayListEditQueue,CurrentSelection)
  921.       ELSE
  922.         DELETE(PlayListEditQueue)
  923.       END
  924.     END
  925.     CASE ACCEPTED()
  926.     OF ?Apply
  927.       DO ApplyChanges
  928.     OF ?OK
  929.       DO ApplyChanges
  930.       POST(Event:CloseWindow)
  931.     OF ?Cancel
  932.       POST(Event:CloseWindow)
  933.     OF ?NewPlayList
  934.       DO SaveEditPlayList
  935.       HoldPlayListName = EditPlayListTitle('')
  936.       IF HoldPlayListName
  937.         HoldPlayListText = ''
  938.         ADD(HoldPlayLists)
  939.         DO LoadEditPlayList
  940.         ENABLE(?EditPlayListName,?PlayListEditQueue)
  941.         ENABLE(?EditPlayList,?DeletePlayList)
  942.         EditPlayListName = HoldPlayListName
  943.         DISPLAY
  944.       END
  945.     OF ?EditPlayList
  946.       HoldPlayListName = EditPlayListTitle(HoldPlayListName)
  947.       PUT(HoldPlayLists)
  948.       EditPlayListName = HoldPlayListName
  949.       DISPLAY
  950.     OF ?DeletePlayList
  951.       IF MESSAGE('Are you sure you want to delete this play list?','Confirm Deletion',ICON:Question,Button:Yes+Button:No,Button:No) = Button:Yes
  952.         DELETE(HoldPlayLists)
  953.         IF RECORDS(HoldPlayLists)
  954.           GET(HoldPlayLists,1)
  955.           DO LoadEditPlayList
  956.           EditPlayListName = HoldPlayListName
  957.           ?EditPlayListName{Prop:Selected} = 1
  958.         ELSE
  959.           EditPlayListName = ''
  960.           FREE(PlayListEditQueue)
  961.           DISABLE(?EditPlayListName,?PlayListEditQueue)
  962.           DISABLE(?EditPlayList,?DeletePlayList)
  963.           CLEAR(HoldPlayLists)
  964.         END
  965.         DISPLAY
  966.       END
  967.     OF ?EditPlayListName
  968.       DO SaveEditPlayList
  969.       GET(HoldPlayLists,CHOICE(?EditPlayListName))
  970.       DO LoadEditPlayList
  971.       DISPLAY
  972.     END
  973.     CASE FIELD()
  974.     OF ?PlayListEditQueue
  975.       CASE EVENT()
  976.       OF Event:DROP
  977.         IF DROPID() = 'Add Track'
  978.           PlayListTrackName = TrackTitle
  979.           PlayListTrackNumber = CHOICE(?TrackList)
  980.           ADD(PlayListEditQueue)
  981.         END
  982.       OF EVENT:Drag
  983.         GET(PlayListEditQueue,CHOICE(?PlayListEditQueue))
  984.       END
  985.     OF ?TrackList
  986.       CASE EVENT()
  987.       OF Event:NewSelection
  988.         GET(TrackList,CHOICE(?TrackList))
  989.         SELECT(?TrackTitle)
  990.         DISPLAY(?TrackTitle)
  991.       OF EVENT:DRAG
  992.         GET(TrackList,CHOICE(?TrackList))
  993.       END
  994.     OF ?TrackTitle
  995.       CASE EVENT()
  996.       OF Event:Accepted
  997.         UPDATE(?TrackTitle)
  998.         PUT(TrackList)
  999.         DISPLAY(?TrackList)
  1000.       OF Event:AlertKey
  1001.         CurrentSelection = ?TrackList{Prop:Selected}
  1002.         UPDATE(?TrackTitle)
  1003.         CASE KEYCODE()
  1004.         OF UpKey
  1005.           PUT(TrackList)
  1006.           IF CurrentSelection = 0
  1007.             ?TrackList{Prop:Selected} = RECORDS(Tracklist)
  1008.           ELSE
  1009.             ?TrackList{Prop:Selected} = CurrentSelection - 1
  1010.           END
  1011.           POST(Event:NewSelection,?TrackList)
  1012.         OF DownKey
  1013.           PUT(TrackList)
  1014.           IF CurrentSelection = RECORDS(TrackList)
  1015.             ?TrackList{Prop:Selected} = 1
  1016.           ELSE
  1017.             ?TrackList{Prop:Selected} = CurrentSelection + 1
  1018.           END
  1019.           POST(Event:NewSelection,?TrackList)
  1020.         OF PgUpKey
  1021.           PUT(TrackList)
  1022.           ?TrackList{Prop:Selected} = CurrentSelection - 15
  1023.           POST(Event:NewSelection,?TrackList)
  1024.         OF PgDnKey
  1025.           PUT(TrackList)
  1026.           ?TrackList{Prop:Selected} = CurrentSelection + 15
  1027.           POST(Event:NewSelection,?TrackList)
  1028.         OF CtrlHome
  1029.         OROF CtrlPgUp
  1030.           PUT(TrackList)
  1031.           ?TrackList{Prop:Selected} = 1
  1032.           POST(Event:NewSelection,?TrackList)
  1033.         OF CtrlEnd
  1034.         OROF CtrlPgDn
  1035.           PUT(TrackList)
  1036.           ?TrackList{Prop:Selected} = RECORDS(TrackList)
  1037.           POST(Event:NewSelection,?TrackList)
  1038.         END
  1039.       END
  1040.     END
  1041.   END
  1042.   RETURN(EditCompleted)
  1043. !----------------------------------------------------------
  1044. ApplyChanges ROUTINE
  1045.   DO SaveEditPlayList
  1046.   PUTINI(CompactDiscID,'Title',CurrentAlbumTitle,'CW_CD.INI')
  1047.   PUTINI(CompactDiscID,'Artist',CurrentAlbumArtist,'CW_CD.INI')
  1048.   LOOP LoopCounter = 1 TO NumberOfTracks
  1049.     GET(TrackList,LoopCounter)
  1050.     PUTINI(CompactDiscID,'Track ' & LoopCounter,TrackTitle,'CW_CD.INI')
  1051.   END
  1052.   PUTINI(CompactDiscID,'PlayList Count',RECORDS(HoldPlayLists),'CW_CD.INI')
  1053.   LOOP LoopCounter = 1 TO RECORDS(HoldPlayLists)
  1054.     GET(HoldPlayLists,LoopCounter)
  1055.     PUTINI(CompactDiscID,'PlayList ' & LoopCounter & ' Title',HoldPlayListName,'CW_CD.INI')
  1056.     PUTINI(CompactDiscID,'PlayList ' & LoopCounter,HoldPlayListText,'CW_CD.INI')
  1057.   END
  1058.   LOOP LoopCounter = RECORDS(HoldPlayLists) + 1 TO PlayListCount
  1059.     PUTINI(CompactDiscID,'PlayList ' & LoopCounter & ' Title',,'CW_CD.INI')
  1060.     PUTINI(CompactDiscID,'PlayList ' & LoopCounter,,'CW_CD.INI')
  1061.   END
  1062.   EditCompleted = True
  1063.  
  1064. !-------------------------------------------------
  1065. LoadEditPlayList ROUTINE
  1066.  
  1067.   FREE(PlayListEditQueue)
  1068.   CurrentSelection = HoldPlayListArray[1]
  1069.   LOOP LoopCounter = 2 TO CurrentSelection + 1
  1070.     PlayListTrackNumber = HoldPlayListArray[LoopCounter]
  1071.     IF NOT PlayListTrackNumber
  1072.       BREAK
  1073.     END
  1074.     GET(TrackList,PlayListTrackNumber)
  1075.     PlayListTrackName = TrackTitle
  1076.     ADD(PlayListEditQueue)
  1077.   END
  1078. !-------------------------------------------------
  1079. SaveEditPlayList ROUTINE
  1080.  
  1081.   HoldPlayListArray[1] = RECORDS(PlayListEditQueue)
  1082.   LOOP LoopCounter = 1 TO HoldPlayListArray[1]
  1083.     GET(PlayListEditQueue,LoopCounter)
  1084.     HoldPlayListArray[LoopCounter + 1] = FORMAT(PlayListTrackNumber,@N2)
  1085.   END
  1086.   PUT(HoldPlayLists)
  1087.  
  1088. !===================================================================
  1089. EditPlayListTitle FUNCTION(PlayListTitle)
  1090.  
  1091. EditedTitle STRING(60)
  1092. ReturnValue STRING(60)
  1093.  
  1094. EditWindow WINDOW('Edit Playlist Title'),AT(,,188,45),FONT('MS Sans Serif',8,,FONT:regular),GRAY
  1095.        PROMPT('Title:'),AT(6,9)
  1096.        ENTRY(@s60),AT(39,6),USE(EditedTitle),REQ,TIP('The name of the playlist')
  1097.        BUTTON('OK'),AT(95,22,40,14),USE(?OK),DEFAULT,REQ,TIP('Accept this playlist name')
  1098.        BUTTON('&Cancel'),AT(139,22,40,14),USE(?Cancel),STD(STD:Close),TIP('Cancel changes to the playlist name')
  1099.      END
  1100.   CODE
  1101.   EditedTitle = PlayListTitle
  1102.   ReturnValue = PlayListTitle
  1103.   OPEN(EditWindow)
  1104.   IF NOT EditedTitle
  1105.     TARGET{Prop:Text} = 'New Playlist Title'
  1106.   END
  1107.   ACCEPT
  1108.     CASE ACCEPTED()
  1109.     OF ?OK
  1110.       UPDATE()
  1111.       ReturnValue = EditedTitle
  1112.       POST(Event:CloseWindow)
  1113.     OF ?Cancel
  1114.       POST(Event:CloseWindow)
  1115.     END
  1116.   END
  1117.   RETURN(ReturnValue)
  1118.  
  1119. !===================================================================
  1120. AboutCDPlayer PROCEDURE
  1121. AboutWindow WINDOW,AT(,,330,120),CENTER,GRAY
  1122.        STRING('The Clarion for Windows Compact Disc Player Example'),AT(37,7,248,16),FONT('Arial',14,,FONT:regular), |
  1123.            CENTER
  1124.        STRING('A hand-coded example, using Windows API calls to provide an interface to the'),AT(31,31,259,10), |
  1125.            CENTER
  1126.        STRING('Windows (Media Control Interface).  '),AT(101,40,120,10),CENTER
  1127.        STRING('Based on code provided by Larry Teames, a member of Team TopSpeed.'),AT(37,55,247,10), |
  1128.            CENTER
  1129.        STRING('The complete code for this application is included as part of Clarion for Window' &|
  1130.            's version 1.5.'),AT(15,73,307,10),USE(?String5)
  1131.        STRING('The total number of executable lines of code is less than 850.'),AT(20,82,281,10),CENTER
  1132.        BUTTON('OK'),AT(145,96),USE(?Button1),STD(STD:Close),DEFAULT
  1133.      END
  1134.   CODE
  1135.   OPEN(AboutWindow)
  1136.   ACCEPT
  1137.   END
  1138. !===================================================================
  1139. SavePlayerStatus PROCEDURE
  1140.   CODE
  1141.   PUTINI('CD Player Settings','Window X',WindowCurrentX,'CW_CD.INI')
  1142.   PUTINI('CD Player Settings','Window Y',WindowCurrentY,'CW_CD.INI')
  1143.   PUTINI('CD Player Settings','Stay On Top',StayOnTop,'CW_CD.INI')
  1144.   PUTINI('CD Player Settings','Control Panel',ControlPanel,'CW_CD.INI')
  1145.   PUTINI('CD Player Settings','Auto Play',AutoPlay,'CW_CD.INI')
  1146.   PUTINI('CD Player Settings','Display Mode',CurrentDisplayFlag,'CW_CD.INI')
  1147.  
  1148. !===================================================================
  1149. AppWindowProc FUNCTION(MyhWnd,usMsg,WParam,IParam)
  1150.  
  1151.     CODE
  1152.     CASE usMsg
  1153.     OF WM_QUERYENDSESSION
  1154.       RETURN(True)
  1155.     OF WM_ENDSESSION
  1156.       SavePlayerStatus
  1157.       RETURN(True)
  1158.     END
  1159.     RETURN(CallWindowProc(CDPlayerWindow,MyhWnd,usMsg,wParam,IParam))
  1160.